﻿@using Vcare.Properties
@model IEnumerable<Vcare.Models.Members>

@{
    ViewBag.Title = "Member Index";
}

<hgroup class="title">
    <h1>@ViewBag.Title.</h1>
</hgroup>

<article>
    <a href="@(Url.Action("Create"))"><img src="../../Images/add.png" /></a>
    <div class="spacer"></div>
</article>

<table class="listtable contactstable" cellspacing="0" cellpadding="0">
    <tr>
        <th class="tableheader clickcolumn">
            @Html.DisplayNameFor(model => model.ContactDate)
        </th>
        <th class="tableheader clickcolumn" style="padding: 10px">
            @Html.DisplayNameFor(model => model.Phone)
        </th>
        <th class="tableheader clickcolumn" style="padding: 10px">
            @Html.DisplayNameFor(model => model.Title)
        </th>
        <th class="tableheader clickcolumn">
            @Html.DisplayNameFor(model => model.Firstname)
        </th>
        <th class="tableheader clickcolumn">
            @Html.DisplayNameFor(model => model.Lastname)
        </th>
        <th class="tableheader clickcolumn">
            @Html.DisplayNameFor(model => model.housenumber)
        </th>
        <th class="tableheader clickcolumn">
            @Html.DisplayNameFor(model => model.Address)
        </th>
        <th class="tableheader clickcolumn">
            @Html.DisplayNameFor(model => model.Town)
        </th>
        <th class="tableheader clickcolumn">
            @Html.DisplayNameFor(model => model.County)
        </th>
        <th class="tableheader clickcolumn">
            @Html.DisplayNameFor(model => model.Postcode)
        </th>
        <th class="tableheader clickcolumn">
            @Html.DisplayNameFor(model => model.Email)
        </th>
        <th class="tableheader clickcolumn">
            @Html.DisplayNameFor(model => model.MembershipID)
        </th>
        <th class="tableheader clickcolumn">
            @Html.DisplayNameFor(model => model.CommentsOnBoxType)
        </th>
        <th class="tableheader clickcolumn">
            Provider
        </th>
        <th class="tableheader clickcolumn">
            @Html.DisplayNameFor(model => model.QAd)
        </th>
        <th class="tableheader clickcolumn"></th>
    </tr>

@foreach (var item in Model)
{
    <tr>
        <td @if (item.DateOfPayment!=null)
	{
		 @:class="paid"
	}>
        @{
            var ContactDate = item.ContactDate.ToShortDateString();
            @ContactDate
         }
        </td>
        <td @if (item.DateOfPayment!=null)
	{
		 @:class="paid"
	}>
            @Html.DisplayFor(modelItem => item.Phone)
        </td>
        <td @if (item.DateOfPayment!=null)
	{
		 @:class="paid"
	}>
            @Html.DisplayFor(modelItem => item.Title)
        </td>
        <td @if (item.DateOfPayment!=null)
	{
		 @:class="paid"
	}>
            @Html.DisplayFor(modelItem => item.Firstname)
        </td>
        <td @if (item.DateOfPayment!=null)
	{
		 @:class="paid"
	}>
            @Html.DisplayFor(modelItem => item.Lastname)
        </td>
        <td @if (item.DateOfPayment!=null)
	{
		 @:class="paid"
	}>
            @Html.DisplayFor(modelItem => item.housenumber)
        </td>
        <td @if (item.DateOfPayment!=null)
	{
		 @:class="paid"
	}>
            @Html.DisplayFor(modelItem => item.Address)
        </td>
        <td @if (item.DateOfPayment!=null)
	{
		 @:class="paid"
	}>
            @Html.DisplayFor(modelItem => item.Town)
        </td>
        <td @if (item.DateOfPayment!=null)
	{
		 @:class="paid"
	}> 
            @Html.DisplayFor(modelItem => item.County)
        </td>
        <td @if (item.DateOfPayment!=null)
	{
		 @:class="paid"
	}>
            @Html.DisplayFor(modelItem => item.Postcode)
        </td>
        <td @if (item.DateOfPayment!=null)
	{
		 @:class="paid"
	}>
            @Html.DisplayFor(modelItem => item.Email)
        </td>
        <td @if (item.DateOfPayment!=null)
	{
		 @:class="paid"
	}>
            @Html.DisplayFor(modelItem => item.MembershipID)
        </td>
       
        <td @if (item.DateOfPayment!=null)
	{
		 @:class="paid"
	}>
            @Html.DisplayFor(modelItem => item.CommentsOnBoxType)
        </td>
        <td @if (item.DateOfPayment != null)
	        {
		         @:class="paid"
	        }>
            @if (item.CallCentreID != null)
            {
                @Html.DisplayFor(modelItem => item.CallCentre.CallCentre)
            }
            else
            {
                @Html.DisplayFor(modelItem => item.Company.Company)
            }
        </td>

        <td @if (item.QAd != null)
            {
		 @:class="paid"
	}>
            @Html.DisplayFor(modelItem => item.QAd)
        </td>
        <td>
        <a href="@(Url.Action("Checkout", new { id = item.MembersID, payment = item.ValueOfSinglePayment }))">
        @if ((this.User.IsInRole(ApplicationRoles.Administrator) || this.User.IsInRole(ApplicationRoles.CallCentreQC))
                && item.DateOfPayment == null && item.QAd != null)
        {
            <img src="../../Images/paypal.jpg" style="width: 20px; height: 20px" />
        }
        </a>
        @if (item.QAd == null)
        {
        <a href="@(Url.Action("Edit", new { id = item.MembersID }))"><img src="../../Images/user_edit.png" /></a>
        <a href="@(Url.Action("Details", new { id = item.MembersID }))"><img src="../../Images/user_go.png" /></a>
            if (ViewBag.Level < 3)
            {
                <a href="@(Url.Action("Delete", new { id = item.MembersID }))"><img src="../../Images/user_delete.png"/></a>
            }
        }
        </td>
    </tr>
}
</table>
<div class="spacer"></div>

